package com.startery;

import org.springframework.data.redis.connection.RedisPassword;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;

public class ConnectionFactory extends LettuceConnectionFactory{
	
	public static  ConnectionFactory connectionFactory;
	
	private ConnectionFactory(RedisStandaloneConfiguration redisStandaloneConfiguration) {
		super(redisStandaloneConfiguration);
		
	}
	
	
	
	public static ConnectionFactory getInstance() {
		if(connectionFactory==null) {
			RedisStandaloneConfiguration redisStandaloneConfiguration=new RedisStandaloneConfiguration();
			redisStandaloneConfiguration.setPassword(RedisPassword.none());;
			redisStandaloneConfiguration.setHostName("127.0.0.1");
			redisStandaloneConfiguration.setPort(6379);
			connectionFactory=new ConnectionFactory(redisStandaloneConfiguration);
			connectionFactory.afterPropertiesSet();//这里不设置报NullPointerException
		}
		return connectionFactory;
	}


}
